home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / mixsd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  6.8 KB  |  243 lines

  1. /*      MIXSD.H
  2.  *
  3.  * Miscellaneous helper functions common to all mixing sound devices.
  4.  * Technically these functions should be part of each Sound Device's internal
  5.  * code, but are here to save some space and help maintenance.
  6.  *
  7.  * $Id: mixsd.h,v 1.2 1997/01/16 18:41:59 pekangas Exp $
  8.  *
  9.  * Copyright 1996,1997 Housemarque Inc.
  10.  *
  11.  * This file is part of the MIDAS Sound System, and may only be
  12.  * used, modified and distributed under the terms of the MIDAS
  13.  * Sound System license, LICENSE.TXT. By continuing to use,
  14.  * modify or distribute this file you indicate that you have
  15.  * read the license and understand and accept it fully.
  16. */
  17.  
  18. #ifndef __MIXSD_H
  19. #define __MIXSD_H
  20.  
  21.  
  22. #include "dma.h"
  23.  
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29.  
  30. extern unsigned GLOBALVAR dmaBufferSize;
  31. extern dmaBuffer GLOBALVAR buffer;
  32. extern unsigned GLOBALVAR dmaPos;
  33.  
  34.  
  35. /****************************************************************************\
  36. *
  37. * Function:     int mixsdInit(unsigned mixRate, unsigned mode,
  38. *                   unsigned dmaChNum)
  39. *
  40. * Description:  Common initialization for all mixing Sound Devices.
  41. *               Initializes DMA functions, DSM, start DMA playback and
  42. *               allocates memory for possible post-processing tables
  43. *
  44. * Input:        unsigned mixRate        mixing rate in Hz
  45. *               unsigned mode           output mode
  46. *               int dmaChNum            DMA channel number / -1
  47. *
  48. * Returns:      MIDAS error code
  49. *
  50. \****************************************************************************/
  51.  
  52. int CALLING mixsdInit(unsigned mixRate, unsigned mode, int dmaChNum);
  53.  
  54.  
  55.  
  56.  
  57. /****************************************************************************\
  58. *
  59. * Function:     int CALLING mixsdClose(void)
  60. *
  61. * Description:  Common uninitialization code for all mixing Sound Devices.
  62. *               Uninitializes DMA playback and DSM and deallocates memory.
  63. *
  64. * Returns:      MIDAS error code
  65. *
  66. \****************************************************************************/
  67.  
  68. int CALLING mixsdClose(void);
  69.  
  70.  
  71.  
  72.  
  73. /****************************************************************************\
  74. *
  75. * Function:     int mixsdGetMode(unsigned *mode)
  76. *
  77. * Description:  Reads the current output mode
  78. *
  79. * Input:        unsigned *mode          pointer to output mode
  80. *
  81. * Returns:      MIDAS error code. Output mode is written to *mode.
  82. *
  83. \****************************************************************************/
  84.  
  85. int CALLING mixsdGetMode(unsigned *mode);
  86.  
  87.  
  88.  
  89. /****************************************************************************\
  90. *
  91. * Function:     int mixsdOpenChannels(unsigned channels)
  92. *
  93. * Description:  Opens sound channels for output. Prepares post-processing
  94. *               tables, takes care of default amplification and finally opens
  95. *               DSM channels. Channels can be closed by simply calling
  96. *               dsmCloseChannels().
  97. *
  98. * Input:        unsigned channels       number of channels to open
  99. *
  100. * Returns:      MIDAS error code
  101. *
  102. \****************************************************************************/
  103.  
  104. int CALLING mixsdOpenChannels(unsigned channels);
  105.  
  106.  
  107.  
  108.  
  109. /****************************************************************************\
  110. *
  111. * Function:     int mixsdSetAmplification(unsigned amplification)
  112. *
  113. * Description:  Sets the amplification level. Calculates new post-processing
  114. *               tables and calls dsmSetAmplification() as necessary.
  115. *
  116. * Input:        unsigned amplification  amplification value
  117. *
  118. * Returns:      MIDAS error code
  119. *
  120. \****************************************************************************/
  121.  
  122. int CALLING mixsdSetAmplification(unsigned amplification);
  123.  
  124.  
  125.  
  126.  
  127. /****************************************************************************\
  128. *
  129. * Function:     int mixsdGetAmplification(unsigned *amplification);
  130. *
  131. * Description:  Reads the current amplification level. (DSM doesn't
  132. *               necessarily know the actual amplification level if
  133. *               post-processing takes care of amplification)
  134. *
  135. * Input:        unsigned *amplification   pointer to amplification level
  136. *
  137. * Returns:      MIDAS error code. Amplification level is written to
  138. *               *amplification.
  139. *
  140. \****************************************************************************/
  141.  
  142. int CALLING mixsdGetAmplification(unsigned *amplification);
  143.  
  144.  
  145.  
  146.  
  147. /****************************************************************************\
  148. *
  149. * Function:     int mixsdSetUpdRate(unsigned updRate);
  150. *
  151. * Description:  Sets the channel value update rate (depends on song tempo)
  152. *
  153. * Input:        unsigned updRate        update rate in 100*Hz (eg. 50Hz
  154. *                                       becomes 5000).
  155. *
  156. * Returns:      MIDAS error code
  157. *
  158. \****************************************************************************/
  159.  
  160. int CALLING mixsdSetUpdRate(unsigned updRate);
  161.  
  162.  
  163.  
  164.  
  165. /****************************************************************************\
  166. *
  167. * Function:     int mixsdStartPlay(void)
  168. *
  169. * Description:  Prepares for playing - reads DMA playing position. Called
  170. *               once before the Sound Device and music player polling loop.
  171. *
  172. * Returns:      MIDAS error code
  173. *
  174. \****************************************************************************/
  175.  
  176. int CALLING mixsdStartPlay(void);
  177.  
  178.  
  179.  
  180.  
  181. /****************************************************************************\
  182. *
  183. * Function:     int mixsdPlay(int *callMP);
  184. *
  185. * Description:  Plays the sound - mixes the correct amount of data with DSM
  186. *               and copies it to DMA buffer with post-processing.
  187. *
  188. * Input:        int *callMP             pointer to music player calling flag
  189. *
  190. * Returns:      MIDAS error code. If enough data was mixed for one updating
  191. *               round and music player should be called, 1 is written to
  192. *               *callMP, otherwise 0 is written there. Note that if music
  193. *               player can be called, mixsdPlay() should be called again
  194. *               with a new check for music playing to ensure the DMA buffer
  195. *               gets filled with new data.
  196. *
  197. \****************************************************************************/
  198.  
  199. int CALLING mixsdPlay(int *callMP);
  200.  
  201.  
  202.  
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206.  
  207.  
  208.  
  209.  
  210.  
  211. /****************************************************************************\
  212. *       enum mixsdFunctIDs
  213. *       ------------------
  214. * Description:  ID numbers for mixing Sound Device common functions
  215. \****************************************************************************/
  216.  
  217. enum mixsdFunctIDs
  218. {
  219.     ID_mixsdInit = ID_mixsd,
  220.     ID_mixsdClose,
  221.     ID_mixsdGetMode,
  222.     ID_mixsdOpenChannels,
  223.     ID_mixsdSetAmplification,
  224.     ID_mixsdGetAmplification,
  225.     ID_mixsdSetUpdRate,
  226.     ID_mixsdStartPlay,
  227.     ID_mixsdPlay
  228. };
  229.  
  230.  
  231.  
  232. #endif
  233.  
  234.  
  235. /*
  236.  * $Log: mixsd.h,v $
  237.  * Revision 1.2  1997/01/16 18:41:59  pekangas
  238.  * Changed copyright messages to Housemarque
  239.  *
  240.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  241.  * Initial revision
  242.  *
  243. */